<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: WebSocket</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Class: WebSocket</h1>
    
    



<section>
    
<header>
    <h2>
        <span class="ancestors"><a href="http.html">vertx/http</a>.</span>
    
    WebSocket
    </h2>
    
</header>  

<article>
    <div class="container-overview">
    
    
    
        
<dt>
    <h4 class="name" id="WebSocket"><span class="type-signature"></span>new WebSocket<span class="signature">(jWebSocket, <span class="optional">server</span>)</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Represents an HTML 5 Websocket</p>
<p>Instances of this class are created and provided to the handler of an
<code>HttpClient</code> when a successful websocket connect attempt occurs.</p>
<p>It implements both <a href="ReadStream.html"><code>ReadStream</code></a> and <a href="WriteStream.html"><code>WriteStream</code></a> so
it can be used with <code>Pump</code> to pump data
with flow control.</p>
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>jWebSocket</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">org.vertx.java.core.http.WebSocketBase</span>


            
            </td>
            
            
                <td class="attributes">
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">The java WebSocketBase object</td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>server</code></td>
            
            
            <td class="type">
            
                
<span class="param-type">boolean</span>


            
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                    
                
                </td>
            
            
            
            
            <td class="description last">whether this is a server-side websocket (default: false)</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line584">line 584</a>
    </li></ul></dd>
    
    
    
    
    
    <dt class="tag-see">See:</dt>
    <dd class="tag-see">
        <ul>
            <li><a href="global.html#WebSocketHandler">WebSocketHandler</a></li>
        </ul>
    </dd>
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
</dd>

    
    </div>
    
    
    
    
        <h3 class="subsection-title">Mixes In</h3>
        
        <ul>
            <li><a href="ReadStream.html">ReadStream</a></li>
        
            <li><a href="WriteStream.html">WriteStream</a></li>
        </ul>
    
    
    
    
    
    
    
    
    
    
    
        <h3 class="subsection-title">Methods</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="binaryHandlerID"><span class="type-signature"></span>binaryHandlerID<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        When a WebSocket is created it automatically registers an event handler
with the eventbus, the ID of that handler is returned.

Given this ID, a different event loop can send a binary frame to that
event handler using the event bus and that buffer will be received by
this instance in its own event loop and written to the underlying
connection. This allows you to write data to other websockets which are
owned by different event loops.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line601">line 601</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    id
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">string</span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="close"><span class="type-signature"></span>close<span class="signature">()</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Close the websocket connection
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line654">line 654</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="closeHandler"><span class="type-signature"></span>closeHandler<span class="signature">(handler)</span><span class="type-signature"> &rarr; {WebSocket}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Set a closed <a href="global.html#Handler"><code>Handler</code></a> on the connection, the handler receives
no parameters.
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>handler</code></td>
            
            
            <td class="type">
            
                
<span class="param-type"><a href="global.html#Handler">Handler</a></span>


            
            </td>
            
            
            
            
            
            <td class="description last">The handler to call when the underlying connection has been closed</td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line646">line 646</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    this
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">WebSocket</span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="headers"><span class="type-signature"></span>headers<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="multi_map-MultiMap.html">module:vertx/multi_map~MultiMap</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        The headers of the handshake request
Only available if this is a server websocket.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line685">line 685</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="multi_map-MultiMap.html">module:vertx/multi_map~MultiMap</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="path"><span class="type-signature"></span>path<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        The path the websocket connect was attempted at.
Only available if this is a server websocket.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line665">line 665</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    path
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">string</span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="reject"><span class="type-signature"></span>reject<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="http.WebSocket.html">module:vertx/http.WebSocket</a>}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Reject the WebSocket. Sends 404 to client
Only available if this is a server websocket.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line675">line 675</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            


<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type"><a href="http.WebSocket.html">module:vertx/http.WebSocket</a></span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="textHandlerID"><span class="type-signature"></span>textHandlerID<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        When a WebSocket is created it automatically registers an event handler
with the eventbus, the ID of that handler is returned.

Given this ID, a different event loop can send a text frame to that
event handler using the event bus and that buffer will be received by
this instance in its own event loop and written to the underlying
connection. This allows you to write data to other websockets which are
owned by different event loops.
    </div>
    

    
    
    
    
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line617">line 617</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    id
</div>



<dl>
	<dt>
		Type
	</dt>
	<dd>
		
<span class="param-type">string</span>


	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="writeBinaryFrame"><span class="type-signature"></span>writeBinaryFrame<span class="signature">(data)</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Write data to the websocket as a binary frame
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>data</code></td>
            
            
            <td class="type">
            
                
<span class="param-type"><a href="buffer-Buffer.html">module:vertx/buffer~Buffer</a></span>


            
            </td>
            
            
            
            
            
            <td class="description last"></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line626">line 626</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="writeTextFrame"><span class="type-signature"></span>writeTextFrame<span class="signature">(data)</span><span class="type-signature"></span></h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        Write data to the websocket as a text frame
    </div>
    

    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>data</code></td>
            
            
            <td class="type">
            
                
<span class="param-type"><a href="buffer-Buffer.html">module:vertx/buffer~Buffer</a></span>


            
            </td>
            
            
            
            
            
            <td class="description last"></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="http.js.html">vertx/http.js</a>, <a href="http.js.html#line635">line 635</a>
    </li></ul></dd>
    
    
    
    
    
    
    
</dl>

    
    

    

    
    
    
    
    
    
    
</dd>

        </dl>
    
    
    
    
    
</article>

</section>  




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-vertx.html">vertx</a></li><li><a href="buffer.html">vertx/buffer</a></li><li><a href="console.html">vertx/console</a></li><li><a href="container.html">vertx/container</a></li><li><a href="event_bus.html">vertx/event_bus</a></li><li><a href="file_system.html">vertx/file_system</a></li><li><a href="http.html">vertx/http</a></li><li><a href="multi_map.html">vertx/multi_map</a></li><li><a href="net.html">vertx/net</a></li><li><a href="parse_tools.html">vertx/parse_tools</a></li><li><a href="pump.html">vertx/pump</a></li><li><a href="shared_data.html">vertx/shared_data</a></li><li><a href="sockjs.html">vertx/sockjs</a></li><li><a href="timer.html">vertx/timer</a></li></ul><h3>Externals</h3><ul><li><a href="InetSocketAddress.html">InetSocketAddress</a></li><li><a href="Buffer_.html">Buffer</a></li><li><a href="RecordParser.html">RecordParser</a></li><li><a href="SockJSSocket.html">SockJSSocket</a></li></ul><h3>Classes</h3><ul><li><a href="buffer-Buffer.html">Buffer</a></li><li><a href="file_system.AsyncFile.html">AsyncFile</a></li><li><a href="http.HttpClient.html">HttpClient</a></li><li><a href="http.HttpClientRequest.html">HttpClientRequest</a></li><li><a href="http.HttpClientResponse.html">HttpClientResponse</a></li><li><a href="http.HttpServer.html">HttpServer</a></li><li><a href="http.HttpServerFileUpload.html">HttpServerFileUpload</a></li><li><a href="http.HttpServerRequest.html">HttpServerRequest</a></li><li><a href="http.HttpServerResponse.html">HttpServerResponse</a></li><li><a href="http.RouteMatcher.html">RouteMatcher</a></li><li><a href="http.WebSocket.html">WebSocket</a></li><li><a href="multi_map-MultiMap.html">MultiMap</a></li><li><a href="net.NetClient.html">NetClient</a></li><li><a href="net.NetServer.html">NetServer</a></li><li><a href="net.NetSocket.html">NetSocket</a></li><li><a href="pump-Pump.html">Pump</a></li><li><a href="sockjs.SockJSServer.html">SockJSServer</a></li></ul><h3>Mixins</h3><ul><li><a href="ClientSSLSupport.html">ClientSSLSupport</a></li><li><a href="ReadStream.html">ReadStream</a></li><li><a href="ServerSSLSupport.html">ServerSSLSupport</a></li><li><a href="ServerTCPSupport.html">ServerTCPSupport</a></li><li><a href="SSLSupport.html">SSLSupport</a></li><li><a href="TCPSupport.html">TCPSupport</a></li><li><a href="WriteStream.html">WriteStream</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Wed Jul 17 2013 20:27:23 GMT+0100 (BST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>